#include<cstdio>
using namespace std;
#define ri register int
#define ll long long
ll ans, c[55][55];
int a[10], len, n[55], cnt;
ll multiqpl(int a[], int l)
{
    ll res = 1;
    for (ri i = 0;i <= 9;i++) {
        res *= c[l][a[i]];
        l -= a[i];
    }
    return res;
}
int main()
{
    for (char ch = getchar();ch >= '0' && ch <= '9';ch = getchar())a[n[++len] = ch - 48]++;
    c[0][0] = 1;
    for (ri i = 1;i <= len;i++) {
        c[i][0] = c[i][i] = 1;
        for (ri j = 1;j < i;j++)c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
    }
    for (ri i = 1;i <= len;i++) {
        cnt = 0;
        for (ri j = 0;j < n[i];j++)
            if (a[j]) {
                a[j]--;//将j放到第i位上
                ans += multiqpl(a, len - i);
                a[j]++;//将j拿走，换下一个
            }
        a[n[i]]--;
    }
    printf("%lld", ans);
}